package controller

import (
	"ginblog/enum"
	"ginblog/resp"
	"ginblog/service"
	"github.com/gin-gonic/gin"
)

type ProfileController struct {
	profile service.ProfileService
	r       resp.Resp
}

type ProfileConInterface interface {
	ProfileOne(c *gin.Context)
}

func (con ProfileController) ProfileOne(c *gin.Context) {
	// 获取前端传递的参数
	// 获取id
	userName := c.Query("username")
	if userName == "" {
		con.r.RespData(enum.ERROR, enum.ERROR.String(), "数据格式有误！", c)
		return
	}
	profile, code := con.profile.ProfileOne(userName)
	if code != enum.SUCCESS {
		con.r.RespData(code, code.String(), "", c)
		return
	}
	con.r.RespData(code, code.String(), profile, c)
}
